<div class="modal-header">
  <div class="modal-title">{{ record.ID > 0 ? '编辑 ' + record.name + ' 信息' : '新建' }}</div>
</div>
<nz-spin *ngIf="!i" class="modal-spin"></nz-spin>
<div *ngIf="i">
  <form nz-form [formGroup]="validateForm">
    <input nz-input hidden formControlName="ID"/>
    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="name">名称</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="名称必填！">
            <input nz-input formControlName="name" placeholder="权限名称"/>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="alias">别名</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="别名必填！">
            <input nz-input formControlName="alias" placeholder="别名"/>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="uri">请求uri</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请求uri必填！">
            <input nz-input formControlName="uri" placeholder="请求uri"/>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="method">请求方式</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请求方式必填！">
            <nz-select formControlName="method" nzPlaceHolder="请求方式">
              <nz-option nzValue="GET" nzLabel="GET（查看）"></nz-option>
              <nz-option nzValue="POST" nzLabel="POST（创建）"></nz-option>
              <nz-option nzValue="PUT" nzLabel="PUT（更新）"></nz-option>
              <nz-option nzValue="DELETE" nzLabel="DELETE（删除）"></nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="group">所属组</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请求方式必填！">
            <input nz-input formControlName="group" placeholder="请求方式"/>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzFor="description">描述</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <textarea nz-input [rows]="3" placeholder="权限描述" formControlName="description"></textarea>
          </nz-form-control>
        </nz-form-item>
      </div>

    </div>
  </form>
</div>

<div class="modal-footer">
  <button nz-button type="button" (click)="close()">关闭</button>
  <button nz-button type="submit" nzType="primary" (click)="save(validateForm.value)" [disabled]="!validateForm.valid"
          [nzLoading]="http.loading">保存
  </button>
</div>
